{assign $etatvalide   = TEMOIGNAGE_ETAT_VALIDE}
{assign $etatinvalide = TEMOIGNAGE_ETAT_INVALIDE}
{assign $etatarchive  = TEMOIGNAGE_ETAT_ARCHIVE}
{assign $etatsuppr    = TEMOIGNAGE_ETAT_SUPPRIME}

{if $temoignage->statut == $etatvalide} {assign $valide   = "CHECKED"} {else}{assign $valide = ""}{/if}
{if $temoignage->statut == $etatinvalide} {assign $invalide = "CHECKED"}{else}{assign $invalide = ""}{/if}
{if $temoignage->statut == $etatarchive} {assign $archive = "CHECKED"}{else}{assign $archive = ""}{/if}
{if $temoignage->statut == $etatsuppr} {assign $suppr = "CHECKED"}{else}{assign $suppr = ""}{/if}

<div id="main_container">

    {$oZoneHeader}
   

    
    <div class="main_content">
        {$oZoneTopMenu}
        <div class="center_content">  
            <div class="left_content"> 
                {$oZoneLeftMenu}
                <h4>Les témoignages : </h4> 
                    
                <table style="width:240px" id="rounded-corner" summary="2007 Major IT Companies' Profit">
                        {foreach $liste as $item}
                         {if $item->statut == $etatvalide} 
                              {assign $class ='class="bleu-tab-liste"'}
                         {elseif $item->statut == $etatarchive} 
                              {assign $class='class="jaune-tab-liste"'}
                         {elseif $item->statut == $etatsuppr} 
                              {assign $class='class="rouge-tab-liste"'}
                         {else}
                              {assign $class='class="paire-tab-liste"'}
                         {/if}
                         {if $item->statut != $etatsuppr} 
                        <tr >
                            <td {$class} >
                               <a href="{jurl 'temoignage~BoTemoignage:index', array('id'=>$item->temoignage_id)}">Témoignage n°{$item->temoignage_id}</a>
                            </td>
                        </tr>
                        {/if}
                        {/foreach}
                        {if sizeof($liste)}
                            <tr><td>{pagelinks 'temoignage~BoTemoignage:index', array(),$recordCount ,$page, $nbitemparpage, "offset", $properties}</td></tr>
                        {/if}
                </table>
            </div>
    
            <div class="right_content">
                {if $id}
                    <h2>Editer un témoignage</h2> 
                    {assign $disabled = "DISABLED"}
                {else}
                    <h2>Ajouter un témoignage</h2> 
                    {assign $disabled = ""}

                {/if} 
                    
                <form action="{jurl 'temoignage~BoTemoignage:sauvegarder'}" method="post" id="editTemoignage" name="editTemoignage" >
                    <input type="hidden" name="id" value="{$temoignage->temoignage_id}" />
                   <dl>
                        <dt><label>Vendeur : </label></dt>
						{if !$id}
						                        <dd>
                            <select name="vendeur" validation="required">
                                <option value="">Sélectionner un vendeur</option>
                                {foreach $vendeur as $vendeurItem}
                                    {if ($vendeurItem->IdVendeur == $temoignage->vendeur_id)} 
                                          {assign $selected='selected="selected"'}
                                    {else}
                                          {assign $selected=''}
                                    {/if}
                                    <option value="{$vendeurItem->IdVendeur}_{$vendeurItem->Vendeur_Nom} " {$selected}>{$vendeurItem->Vendeur_Nom}  {$vendeurItem->Vendeur_Prenom} </option>
                                {/foreach}
                            </select>
                        </dd>
						{else}
							<dd>
                                {if ( isset($vendeurbyid->Vendeur_Nom) && $vendeurbyid->Vendeur_Nom!='' ) }
								    <input type="text" value="{$vendeurbyid->Vendeur_Nom}" disabled>
                                {/if}
                                {if ( isset($temoignage->vendeur_id) && $temoignage->vendeur_id!='' ) }
								   <input type="hidden" value="{$temoignage->vendeur_id}" name="vendeur" />
                                {/if}
								
							</dd>
						{/if}
                    </dl>
                    <dl>
                        <dt><label>Titre *: </label></dt>
                        <dd><input type="text"  value="{$temoignage->temoignage_titre}" name="titre"  validation="required"/></dd>
                    </dl>
                    <dl style="height:auto">
                        <dt><label>Contenu : </label></dt>
                        <dd style="width:600px;">
                            <textarea id="content" name="content"  validation="required" > {$temoignage->temoignage_description}</textarea>
                            <script type="text/javascript">
                                {literal}CKEDITOR.replace( 'content', {width:'600px', toolbar:'AOToolbar'}) ;{/literal}
                            </script>
                        </dd>
                    </dl>
                    <dl>
                        <dt><label>Département : </label></dt>
                        <dd>
                            <select name="departement" validation="required">
                                <option value="">Sélectionner un département</option>
                                {foreach $departement as $departementItem}
                                    {if ($departementItem->departement_id == $temoignage->location)} 
                                          {assign $selected='selected="selected"'}
                                    {else}
                                          {assign $selected=''}
                                    {/if}
                                    <option value="{$departementItem->departement_id}" {$selected}>{$departementItem->departement_nom}</option>
                                {/foreach}
                            </select>
                        </dd>
                     </dl>
                     </dl>

                     <dl>
                        <dt><label>Date de validation : </label></dt>
                        <dd><input type="text"  value="{$temoignage->date_validation|jdatetime:'db_date':'lang_date'}" name="datevalide"  id="datepicker" /></dd>
                     </dl>

                     <dl>
                        <dt><label>Date de refus : </label></dt>
                        <dd><input type="text"  value="{$temoignage->date_refus|jdatetime:'db_date':'lang_date'}" name="daterefus"  id="datepicker2"/></dd>
                     </dl>

                     <dl>
                        <dt><label>Date de suppression : </label></dt>
                        <dd><input type="text"  value="{$temoignage->date_suppr|jdatetime:'db_date':'lang_date'}" name="datesuppr" id="datepicker3" /></dd>
                     </dl>

                     <dl>
                        <dt><label class="nPadd">&nbsp;</label></dt>
                        <dd class="validite6">
                            <input type="radio" name="status"   value="{$etatvalide}" {$valide}/><div class="marge6">Valide<div class="legende" id="valide">&nbsp;</div></div>
                            <input type="radio" name="status"   value="{$etatinvalide}"  {$invalide}/><div class="marge6">Invalide<div class="legende" id="invalide"></div></div>
                            <input type="radio" name="status"   value="{$etatarchive}" {$archive}/><div class="marge6">Archivé<div class="legende" id="archive"></div></div>
                        </dd>
                      </dl>
                    {if $annonce}
                     <dl>
                        <dt style="width:200px"><label class="nPadd"><a href="{jurl 'recherche~FoFiche:index', array('id'=>$annonce->IdOccasion)}"  target='_blank'>Véhicule du vendeur : {$annonce->Occas_NumImmatricul}</a></label></dt>
                        <dd>
                            
                        </dd>
                      </dl>
                    {/if}

                    <dl class="submit">
                        <input  id ="valider-annonce" class="valider" title="Valider" type="submit" value="" style="margin-right:10px;"/>
                        <a title="Annuler" href="{jurl 'temoignage~BoTemoignage:index'}" class="bt_green"><span class="bt_green_lft"></span><strong>Annuler</strong><span class="bt_green_r"></span></a>
                        {if $temoignage->temoignage_id}
                        <a title="Annuler" href="{jurl 'temoignage~BoTemoignage:supprimer', array('id'=>$temoignage->temoignage_id)}" class="bt_green"><span class="bt_green_lft"></span><strong>Supprimer</strong><span class="bt_green_r"></span></a>
                        {/if}

                    </dl>
                 </form>

            </div><!-- end of right content-->
        </div>   <!--end of center content -->               

        <div class="clear"></div>
    </div> <!--end of main content-->
    
    
    <div class="footer">
    </div>

</div>

 {literal} 
         <style  type="text/css">

                .error input {border:1px solid red !important;}
                .error textarea {border:1px solid red !important;}
                .errorlist li {font-size: 0.8em;}

                td.bleu-tab-liste , span#valide{background-color:#99CCFF !important;}
                td.jaune-tab-liste, span#archive{background-color:#FFFF99 !important;}
                td.rouge-tab-liste, span#suppr{background-color:#C92828 !important;}
                td .paire-tab-liste, span#invalide { background-color:#CCCCCC !important; }
                td a {color:#7C7777 !important;}

                /*Légende calidité code couleur libellé*/
                div.legende {width:30px; height:13px; display:inline-block; margin:0 15px 0 0;}
                div#valide{background-color:#99CCFF !important;}
                div#archive{background-color:#FFFF99 !important;}
                div#suppr{background-color:#C92828 !important;}
                div#invalide { background-color:#CCCCCC !important; }

          </style>

          <script type="text/javascript">
                $(function(){
                    $( "#datepicker" ).datepicker({dateFormat: 'dd/mm/yy'});
                    $( "#datepicker2" ).datepicker({dateFormat: 'dd/mm/yy'});
                    $( "#datepicker3" ).datepicker({dateFormat: 'dd/mm/yy'});

                // form validation
                var test = $("#editTemoignage");
                test.validation();
                test.submit(function(e) {
                    $("#valid-form").remove();
                    if(test.validate()) {
                        document.forms["editTemoignage"].submit();
                    }
                    e.preventDefault();
                });

              });
          </script>

  {/literal}